<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function fn (str) {
        var res = str.split('')
        var str2 = ''
        for(var i = 0 ; i < res.length ; i++){
            if(res[i] >= 'a' && res[i] <= 'z'){
                str2 += res[i].toUpperCase()
            }
            if(res[i] >= 'A' && res[i] <= 'Z'){
                str2 += res[i].toLowerCase()
            }
        }
        return str2
    }

    str = 'afdafASFES'
    var res = fn (str)
    console.log(res);
</script>